package com.qu.tabhost.tabs;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.qu.tabhost.OnReselectListener;
import com.qu.tabhost.R;
import com.qu.tabhost.tabs.widget.NavigationButton;

public class TabActivity extends AppCompatActivity implements NavFragment.OnNavigationReselectListener{
    private NavFragment nav;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tab);
        FragmentManager manager = getSupportFragmentManager();
        nav = (NavFragment) manager.findFragmentById(R.id.nav_button);
        nav.setup(manager,R.id.container,this,this);
    }

    @Override
    public void onReselect(NavigationButton navButton) {
        Fragment fragment = navButton.getFragment();
        if(fragment != null){
            if(fragment instanceof OnReselectListener){
                ((OnReselectListener) fragment).onReselect();
            }
        }
    }

}
